package com.heima.behavior.controller.v1;

import com.heima.behavior.service.*;
import com.heima.model.behavior.dtos.*;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1")
@Api("用户行为")
public class BehaviorController {
    @Autowired
    private ApBehaviorEntryService apBehaviorEntryService;
    @Autowired
    private ApReadBehaviorService apReadBehaviorService;
    @Autowired
    private ApUnlikeBehaviorService apUnlikeBehaviorService;
    @Autowired
    private ApCollectionBehaviorService apCollectionBehaviorService;
    @Autowired
    private ApArticleBehaviorService apArticleBehaviorService;

    @ApiOperation(value = "点赞",tags = "点赞")
    @PostMapping("/likes_behavior")
    public ResponseResult LikeOrCancel(@RequestBody @Validated LikesBehaviorDTO likesBehaviorDTO){
        return apBehaviorEntryService.LikeOrCancel(likesBehaviorDTO);
    }

    @ApiOperation(value = "阅读",tags = "阅读")
    @PostMapping("/read_behavior")
    public ResponseResult read_behavior(@RequestBody @Validated ReadBehaviorDTO readBehaviorDTO){
        return apReadBehaviorService.readBehavior(readBehaviorDTO);
    }


    @ApiOperation(value = "不喜欢",tags = "不喜欢")
    @PostMapping("/un_likes_behavior")
    public ResponseResult un_likes_behavior(@RequestBody @Validated UnLikesBehaviorDTO unLikesBehaviorDTO){
        return apUnlikeBehaviorService.unlikeBehavior(unLikesBehaviorDTO);
    }

    @ApiOperation(value = "收藏",tags = "收藏")
    @PostMapping("/collection_behavior")
    public ResponseResult collection_behavior(@RequestBody @Validated CollectionBehaviorDTO collectionBehaviorDTO){
        return apCollectionBehaviorService.collectBehavior(collectionBehaviorDTO);
    }


    @ApiOperation(value = "行为",tags = "行为")
    @PostMapping("article/load_article_behavior/")
    public ResponseResult load_article_behavior(@RequestBody @Validated ArticleBehaviorDTO articleBehaviorDTO){
        return apArticleBehaviorService.loadArticleBehavior(articleBehaviorDTO);
    }
}
